using System;
using System.Collections;
using System.Threading;
using System.IO;
using Scenario.WorkflowEngine.DataModel.WorkflowApplicationsData;
using Scenario.WorkflowEngine.DataModel.Common;

namespace Scenario.Applications
{
    class Sample
	{
	    public Sample()
		{
		}
        [STAThread]
		static void Main(string[] args)
		{
            ApplicationHelper application = new ApplicationHelper();

            Sample sample = new Sample();
			
			//Callbacks
			CallBack cb = new CallBack( sample.One );
			application.AddCallBack( cb, "One" );

			//starting Application
            application.StartUp("Scenario.Applications.StandAlone.Simple");
        }

        public String One(String sFunction)
        {
            Console.WriteLine("\nCallback called with param: {0}", sFunction);

            XMLApplicationFunction function = new XMLApplicationFunction();
            function.Parse(sFunction);

            XMLFormalParameters vParameters = function.XMLFormalParameters;

            for (int i = 0; i < vParameters.Count; i++)
            {
                XMLFormalParameter parameter = (XMLFormalParameter)vParameters[i];
                System.Console.WriteLine("Parameter In {0} {1}", parameter.Name, parameter.Value);
            }

            XMLApplicationFunctionResult result = new XMLApplicationFunctionResult();
            result.Code = 0;
            result.Message = "Message";
            XMLFormalParameters vRsParameters = result.XMLFormalParameters;
            vRsParameters.Add(new XMLFormalParameter("Uno", "Uno", XMLFormalParameter.STRING_TYPE));
            vRsParameters.Add(new XMLFormalParameter("Due", "Uno", XMLFormalParameter.STRING_TYPE));

            return result.GetXML();
        }
    }
}
